package com.ruoyi.web.tdm.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.web.tdm.domain.TdmShiYanXiangDao;
import com.ruoyi.web.tdm.service.ITdmShiYanXiangDaoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 实验向导Controller
 * 
 * @author ly
 * @date 2022-03-14
 */
@RestController
@RequestMapping("/tdm/TdmShiYanXiangDao")
public class TdmShiYanXiangDaoController extends BaseController
{
    @Autowired
    private ITdmShiYanXiangDaoService tdmShiYanXiangDaoService;

    /**
     * 查询实验向导列表
     */
//    @PreAuthorize("@ss.hasPermi('tdm:TdmShiYanXiangDao:list')")
    @GetMapping("/list")
    public TableDataInfo list(TdmShiYanXiangDao tdmShiYanXiangDao)
    {
        startPage();
        List<TdmShiYanXiangDao> list = tdmShiYanXiangDaoService.selectTdmShiYanXiangDaoList(tdmShiYanXiangDao);
        return getDataTable(list);
    }

    /**
     * 导出实验向导列表
     */
//    @PreAuthorize("@ss.hasPermi('tdm:TdmShiYanXiangDao:export')")
    @Log(title = "实验向导", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TdmShiYanXiangDao tdmShiYanXiangDao)
    {
        List<TdmShiYanXiangDao> list = tdmShiYanXiangDaoService.selectTdmShiYanXiangDaoList(tdmShiYanXiangDao);
        ExcelUtil<TdmShiYanXiangDao> util = new ExcelUtil<TdmShiYanXiangDao>(TdmShiYanXiangDao.class);
        util.exportExcel(response, list, "实验向导数据");
    }

    /**
     * 获取实验向导详细信息
     */
//    @PreAuthorize("@ss.hasPermi('tdm:TdmShiYanXiangDao:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tdmShiYanXiangDaoService.selectTdmShiYanXiangDaoById(id));
    }

    /**
     * 新增实验向导
     */
//    @PreAuthorize("@ss.hasPermi('tdm:TdmShiYanXiangDao:add')")
    @Log(title = "实验向导", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TdmShiYanXiangDao tdmShiYanXiangDao)
    {
        return toAjax(tdmShiYanXiangDaoService.insertTdmShiYanXiangDao(tdmShiYanXiangDao));
    }

    /**
     * 修改实验向导
     */
//    @PreAuthorize("@ss.hasPermi('tdm:TdmShiYanXiangDao:edit')")
    @Log(title = "实验向导", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TdmShiYanXiangDao tdmShiYanXiangDao)
    {
        return toAjax(tdmShiYanXiangDaoService.updateTdmShiYanXiangDao(tdmShiYanXiangDao));
    }

    /**
     * 删除实验向导
     */
//    @PreAuthorize("@ss.hasPermi('tdm:TdmShiYanXiangDao:remove')")
    @Log(title = "实验向导", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tdmShiYanXiangDaoService.deleteTdmShiYanXiangDaoByIds(ids));
    }
}
